Release 10.1A: OpenEdge Development:
Progress Dynamics Advanced Development


Additional query methods

Use either the modifyNewRecord method or the collectChanges method to make changes to records.

modifyNewRecord

The standard entry points for writing data validation are described in the business logic chapters in OpenEdge Development: Progress Dynamics Basic Development . However, there is an additional new entry point available to developers so that you can make changes to a newly created record before it is first displayed, normally to assign initial values. This is the modifyNewRecord method. There is no standard code for this procedure, but it is run NO-ERROR during record creation in the SDO. Therefore, any code you write for it in your SDO data logic procedure is executed at the proper time. It takes no parameters, but you can refer to the temp-table record buffer in the same way that you do for validation procedures, using b_ plus the name of the primary table for the SDO.

Keep in mind that because modifyNewRecord is executed only in the client-side SDO, it will not be effective for initializing a record using a WebSpeed front-end to the application.

Here is a simple example for our Customer SDO, which initializes several of the fields assuming that the Customer is from New Hampshire:

Procedure modifyNewRecord: 
/*------------------------------------------------------------------------- 
  Purpose:   Custom code for new records to initialize some of the fields 
             in the Customer table.   
  Parameters:  <none> 
  Notes:       This is called automatically on Add or Copy. 
-------------------------------------------------------------------------*/ 
ASSIGN b_customer.State = 'NH' 
       b_customer.phone = '(603)' 
       b_customer.fax = '(603)' 
       b_customer.postalcode = '030xx' 
       b_customer.comments = "Here's another New Hampshire Customer!". 
END PROCEDURE. 

When you run the Customer Maintenance application window and select Add, you see the initial values shown in Figure 5–4.

Figure 5–4: Customer maintenance window

collectChanges

The collectChanges named event is published automatically when a Save occurs. The event cascades down through any visual objects that contribute changes to the current record, such as multiple viewers with updateable fields from a single SDO.

It takes two INPUT-OUTPUT parameters that give each of these objects (viewers on different pages of a folder, for example) the opportunity to add their own changes and information about the changes to the growing list, passing it from procedure to procedure, as shown:

Procedure collectChanges: 
  Params: INPUT-OUTPUT PARAMETER pcChanges AS CHARACTER 
          INPUT-OUTPUT PARAMETER pcInfo    AS CHARACTER. 
Candidate for: override 
  You can create a local version of this procedure if your code needs to 
intercept the collecting of modified fields from the different objects in the 
window that have them, for example to adjust the changed values, contribute 
additional ones, or trigger some other related event. 


Copyright © 2005 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095